package leetcode_day._2021._202106._1120;

/**
 * @author yzh
 * @version 1.0
 * @date 2021/6/13 17:23
 * 第一个错误的版本
 * 算法：二分查找
 */
public class _13_278 {
    public static void main(String[] args) {
        System.out.println(4 >> 1);
    }

    public int firstBadVersion(int n) {
        int start = 1, end = n;
        while (start < end) {
            // 主要是这里，普通写法会超时
            int mid = start + (end - start) / 2;
            if (isBadVersion(mid)) end = mid;
            else start = mid + 1;
        }
        return start;
    }

    private boolean isBadVersion(int version) {
        return false;
    }

}
